﻿using System;
using System.Linq.Expressions;

namespace NHibernate.Expression.Extensions.Helpers {
	public static class ExpressionExtensions {
		public static string MemberName<T, R>(this Expression<Func<T, R>> f) {
			var expr = f.Body as MemberExpression;
			if (expr == null) {
				var u = f.Body as UnaryExpression;
				expr = u.Operand as MemberExpression;
			}
			return expr.Member.Name;
		}
	}
}